package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.MesProducePassStationDetail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2022-03-30 15:30:52
 */
@Repository
public class MesProducePassStationDetailDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(MesProducePassStationDetailDao.class);

    public MesProducePassStationDetail insert(final MesProducePassStationDetail mesProducePassStationDetail) {
        insert("MesProducePassStationDetail.insert", mesProducePassStationDetail);
        return mesProducePassStationDetail;
    }

    public Boolean updateInfoById(final MesProducePassStationDetail mesProducePassStationDetail) {
        return update("MesProducePassStationDetail.updateInfoById", mesProducePassStationDetail) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("MesProducePassStationDetail.updateInfoByQuery", query) > 0;
    }

    public MesProducePassStationDetail selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("MesProducePassStationDetail.selectById", query);
    }

    public List<MesProducePassStationDetail> selectByQuery(final Query query) {
        return queryForList("MesProducePassStationDetail.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("MesProducePassStationDetail.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        MesProducePassStationDetail mesProducePassStationDetail = new MesProducePassStationDetail();
        mesProducePassStationDetail.setDeleteFlag(1);
        mesProducePassStationDetail.setId(id);
        mesProducePassStationDetail.setEntId(entId);

        return update("MesProducePassStationDetail.updateInfoById", mesProducePassStationDetail) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("MesProducePassStationDetail.deleteById", query) > 0;
    }
}